using System;
using KJFramework.Dynamic.Contracts;
using KJFramework.Platform.Client.ProtocolStack;

namespace KJFramework.Platform.Deploy.DSC.CP.Client.Contracts
{
    internal class ComponentTunnelService : IComponentTunnelContract
    {
        #region Implementation of IComponentTunnelContract

        public void Transport(object obj)
        {
            ClientMessage message = (ClientMessage) obj;
            message.Bind();
            Guid[] channelIds = Client.GetClient(message.Header.ClientTag);
            if (channelIds != null)
            {
                foreach (Guid guid in channelIds)
                {
                    Global.CommnicationNode.Send(guid, message.Body);
                }
            }
        }

        #endregion
    }
}